package ModelLayer;
import java.util.*;


public class Person
{
    public long id;
    private String name;
    private String address;
    private String postalCode;
    private String city;
    private String phone;
    private ArrayList<Loan> loans;
    
    /* Constructor for class Person */
    public Person(long id, String name, String address, String postalCode, String city, String phone )
    {
        this.id = id;
        this.name = name;
        this.address = address;
        this.postalCode = postalCode;
        this.city = city;
        this.phone = phone;
        loans = new ArrayList<>();
    }
    
    public Person()
    {
        id = 12753943;
        name = "Johnny";
        address = "Herningvej 210";
        postalCode = "9220";
        city = "Aalborg";
        phone = "29658208";
    }

    /* Print method with all information */
    public void printDetails()
    {
        System.out.println("ID : " + id);
        System.out.println("Name : " + name);
        System.out.println("Address : " + address);
        System.out.println("Postal code : " + postalCode);
        System.out.println("City : " + city);
        System.out.println("Phone : " + phone);
    }
    
    /* Get methods */
    public long getId()
    {
        return id;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getAddress()
    {
        return address;
    }
    
    public String getPostalCode()
    {
        return postalCode;
    }
    
    public String getCity()
    {
        return city;
    }
    
    public String getPhone()
    {
        return phone;
    }
    
    /* Set methods */
    public void setName(String name)
    {
        this.name = name;
    }
    
     public void setAddress(String address)
    {
        this.address = address;
    }
    
     public void setPostalCode(String postalCode)
    {
        this.postalCode = postalCode;
    }
    
     public void setCity(String city)
    {
        this.city = city;
    }
    
     public void setPhone(String phone)
    {
        this.phone = phone;
    }    
    
    /* Function for adding loan */
    public void addLoan(Loan loan)
    {
        loans.add(loan);
    }
    
    /* Function for find a specific loan after id */
    public Loan getLoan(long id)
    {
        for(Loan loan : loans)
        {
            if(loan.getId() == id) {
                return loan;
            }
        }
        return null;
    }
    
}